﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace HTDW_Framework
{
    public sealed partial class HTDW
    {
        private static MonoBehaviour _mainMonoBehaviour = null;
        private static GameObject _mainGameObject = null;
        private static Camera _mainCamera = null;

        private static bool _lockInitList = false;
        private static List<I_Init> _initList = new List<I_Init>();
        private static bool _lockUpdateList = false;
        private static List<I_Update> _updateList = new List<I_Update>();
        private static bool _lockLateUpdateList = false;
        private static List<I_LateUpdate> _lateUpdateList = new List<I_LateUpdate>();
        private static bool _lockFixedUpdateList = false;
        private static List<I_FixedUpdate> _fixedUpdateList = new List<I_FixedUpdate>();
        private static bool _lockDrawList = false;
        private static List<I_Draw> _drawList = new List<I_Draw>();
        private static bool _lockEventList = false;
        private static List<I_Event> _eventList = new List<I_Event>();

        /// <summary>
        /// 此程序主MonoBehaviour
        /// </summary>
        public static MonoBehaviour mainMonoBehaviour
        {
            get { return _mainMonoBehaviour; }
        }
        /// <summary>
        /// 此程序主游戏对象
        /// </summary>
        public static GameObject mainGameObject
        {
            get { return _mainGameObject; }
        }
        /// <summary>
        /// 此程序主相机
        /// </summary>
        public static Camera mainCamera
        {
            get { return _mainCamera; }
        }
        /// <summary>
        /// 此主程序当前帧率
        /// </summary>
        public static int fps
        {
            get 
            {
                if (Time.time > _fps_time + 1)
                {
                    _fps_fps = (Time.frameCount - _fps_fpsCunt) / ((int)Time.time - _fps_time);
                    _fps_time = (int)Time.time;
                    _fps_fpsCunt = Time.frameCount;
                }
                return _fps_fps;
            }
            set
            {
                if (value < -1)
                {
                    QualitySettings.vSyncCount = 2;
                    Application.targetFrameRate = -1;
                }
                else if (value < 1)
                {
                    QualitySettings.vSyncCount = 1;
                    Application.targetFrameRate = -1;
                }
                else
                {
                    QualitySettings.vSyncCount = 0;
                    Application.targetFrameRate = value;
                }
            }
        }
        private static int _fps_fps = 0, _fps_time = 0, _fps_fpsCunt = 0;




        public static int AddUpdate(int order)
        {
            return 0;
        }
        public static int SetUpdate(int order)
        {
            return 0;
        }
        public static int GetUpdate(int order)
        {
            return 0;
        }
        public static int DelUpdate(int order)
        {
            return 0;
        }

    }
}